package main

import "math"

func jump(nums []int) int {
	dp := make([]int, len(nums))
	dp[0] = 0

	for i := 1; i < len(nums); i++ {
		dp[i] = math.MaxInt32
	}

	for i := 1; i < len(nums); i++ {
		for j := i - 1; j >= 0; j-- {
			if nums[j]+j >= i {
				if nums[j] > 0 || i == 0 {
					if dp[i] > dp[j]+1 {
						dp[i] = dp[j] + 1
					}
				}
			}
		}
	}

	return dp[len(dp)-1]
}

func main() {
	jump([]int{2, 3, 1, 1, 4})
}
